package org.example.common.configs.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException {


    private static final long serialVersionUID = 4501984877913236291L;
    /**
     * 业务异常编码
     */
    @Getter
    private String code;

    /**
     * 业务异常信息（前端可见的）
     */
    @Getter
    private String message;

    public ServiceException() {
        super();
    }

    public ServiceException(String code) {
        this.code = code;
    }

    public ServiceException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorEnum errorEnum) {
        this(errorEnum.getCode(), errorEnum.getMsg());
    }


}
